<script setup lang='ts'>
import { ref } from 'vue'
import Child from './15-子传父子组件.vue'
const username = ref('张三')
const age = ref(18)
const change = () => {
  username.value = '李四'
  age.value++
}

//父组件定义函数
const receiveAge = (count: number) => {
  age.value = count
}
const receiveAll = (count: number, name: string) => {
  username.value = name
  age.value = count
}
</script>

<template>
  <div class="father">
    <h1>当前组件</h1>
    <p>姓名：{{ username }}</p>
    <p>年龄：{{ age }}</p>
    <button @click="change">点击</button>
    <Child :name="username" :age="age" :func="receiveAge" @updat-age="receiveAge" @update-all="receiveAll" />
  </div>
</template>

<style scoped></style>